package com.example.basicknowledge.带返回值的跳转;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.EditText;

import com.example.basicknowledge.R;

public class NextActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.next_activity);
    }

    @Override
    public void onBackPressed() {
        EditText editText = (EditText)findViewById(R.id.editText);
        String string = editText.getText().toString();
        setResult(2,(new Intent()).setAction(string));
        super.onBackPressed();
        finish();
    }
}
